<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /* 苹果3元一个，鸭梨2元一个，桃子1元一个。现在想用200元正好买100个水果，在控制台中列出所有可能性 */
        var apple, pear, peach;
        for(var i = 1; i <= 100; i++) {
            for(var j = 1; j < (100 - i); j++) {
                for (k = 1; k <(100 - i - j); k++){
                    if(i * 3 + j * 2 + k == 200){
                        console.log("苹果" + i + "个，鸭梨" + j + "个,桃子" + k + "个");
                    }
                }
            }
        }
        
    </script>
</body>
</html>